speaker2 2.2.1
Loading...
Searching...
No Matches
speaker2


Speaker 2 Click

Speaker 2 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Nov 2024.
  • Type : SPI type

Software Support

Example Description

This example demonstrates the use of the Speaker 2 Click board. It initializes the board and plays predefined voice messages or sound effects through the speaker module. Supported voices include numbers (ONE to SIX) and sound effects like FAST BEEP.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Speaker2

Example Key Functions

Application Init

Initializes the logger module, configures the Speaker 2 Click board, and applies the default settings to reset the device, power it up, verify communication, and load an example audio project into the device memory.

void application_init ( void )
{
log_cfg_t log_cfg;
speaker2_cfg_t speaker2_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
speaker2_cfg_setup( &speaker2_cfg );
if ( SPI_MASTER_ERROR == speaker2_init( &speaker2, &speaker2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( SPEAKER2_ERROR == speaker2_default_cfg ( &speaker2 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define SPEAKER2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition speaker2.h:282
void application_init(void)
Definition main.c:36
#define MIKROBUS_POSITION_SPEAKER2
Definition main.c:30
@ SPEAKER2_ERROR
Definition speaker2.h:363

Application Task

Sequentially plays predefined voice messages and sound effects from the Speaker 2 Click board while logging the playback status (DONE or ERROR) for each sound.

void application_task ( void )
{
log_printf ( &logger, " Playing voice ONE: %s\r\n\n", ( char * )
( ( SPEAKER2_OK == speaker2_play_voice ( &speaker2, SPEAKER2_VP9_ONE ) ) ? "DONE" : "ERROR" ) );
log_printf ( &logger, " Playing voice TWO: %s\r\n\n", ( char * )
( ( SPEAKER2_OK == speaker2_play_voice ( &speaker2, SPEAKER2_VP10_TWO ) ) ? "DONE" : "ERROR" ) );
log_printf ( &logger, " Playing voice THREE: %s\r\n\n", ( char * )
( ( SPEAKER2_OK == speaker2_play_voice ( &speaker2, SPEAKER2_VP11_THREE ) ) ? "DONE" : "ERROR" ) );
log_printf ( &logger, " Playing voice FOUR: %s\r\n\n", ( char * )
( ( SPEAKER2_OK == speaker2_play_voice ( &speaker2, SPEAKER2_VP12_FOUR ) ) ? "DONE" : "ERROR" ) );
log_printf ( &logger, " Playing voice FIVE: %s\r\n\n", ( char * )
( ( SPEAKER2_OK == speaker2_play_voice ( &speaker2, SPEAKER2_VP13_FIVE ) ) ? "DONE" : "ERROR" ) );
log_printf ( &logger, " Playing voice SIX: %s\r\n\n", ( char * )
( ( SPEAKER2_OK == speaker2_play_voice ( &speaker2, SPEAKER2_VP14_SIX ) ) ? "DONE" : "ERROR" ) );
log_printf ( &logger, " Playing voice FAST BEEP: %s\r\n\n", ( char * )
( ( SPEAKER2_OK == speaker2_play_voice ( &speaker2, SPEAKER2_VP15_FAST_BEEP ) ) ? "DONE" : "ERROR" ) );
}
#define SPEAKER2_VP10_TWO
Definition speaker2.h:229
#define SPEAKER2_VP14_SIX
Definition speaker2.h:233
#define SPEAKER2_VP12_FOUR
Definition speaker2.h:231
#define SPEAKER2_VP15_FAST_BEEP
Definition speaker2.h:234
#define SPEAKER2_VP9_ONE
Definition speaker2.h:228
#define SPEAKER2_VP13_FIVE
Definition speaker2.h:232
#define SPEAKER2_VP11_THREE
Definition speaker2.h:230
void application_task(void)
Definition main.c:72
@ SPEAKER2_OK
Definition speaker2.h:362

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.